<template>
	<view class="page-delay">
		<view class="condition">
			<view class="conmenus">
				<view class="conleft">{{$t('defect.defInfo.postPoneTime')}}<span class="redx">*</span></view>
				<view class="conright">
					<date-picker mode="dateTime" :showValue="delayDate" @change="dateChange">
						{{ delayDate || $t('baseCommon.message.pleaseSelect', { title: '' }) }}
					</date-picker>
				</view>
			</view>
			<view class="contexts">
				<view class="conleft">{{$t('defect.defInfo.postPoneReason')}}</view>
				<view class="coninputright">
					<textarea :placeholder="$t('baseCommon.message.pleaseEnter', { title: '' })" auto-height v-model="delayDesc"/>
				</view>
			</view>
		</view>
		
		<view class="button-popup">
			<button type="primary" @click="submit">{{$t('baseCommon.buttons.submit')}}</button>
			<button type="default" @click="reset">{{$t('baseCommon.buttons.reset')}}</button>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			data: {
				type: Object,
				default() {
					return {}
				}
			},
			planEndTime: {
				type: String,
				default() {
					return ""
				}
			},
			operationTeamNo: {
				type: String,
				default() {
					return ""
				}
			}
		},
		data() {
			return {
				formData: this.data,
				delayDate: this.data.changeTime ? this.data.changeTime : this.planEndTime,
				delayDesc: this.data.changeDesp
			}
		},
		methods: {
			dateChange(e) {
				this.delayDate = e
			},
			submit() {
				this.formData.changeTime = this.delayDate
				this.formData.changeDesp = this.delayDesc
				this.formData.changeType = "yqsq"
				this.$emit("getRecord", this.formData)
				
				let projectType = uni.getStorageSync("projectType")
				if(projectType == "wind") {
					let that = this
					uni.navigateTo({
						url: "/pages/base/select-user-multi?type=delay&groupId="+this.operationTeamNo,
						events: {
							selectUserMulti(data) {
								that.$emit("close", "delay", data)
							}
						}
					})
				} else if(projectType == "fire") {
					this.$emit("close", "delay")
				}
			},
			reset() {
				this.delayDate = ""
				this.delayDesc = ""
			}
		}
	}
</script>

<style lang="scss">
	@import '@/static/style/common-detail.scss';
	
	.page-delay {
		overflow-y: auto;
		background-color: #fff;
		width: 350px;
	}
</style>
